import { type App, type Plugin, type Component } from 'vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import './styles/index.scss'

// 导入自定义组件
import YqSelect from './components/select/YqSelect.vue'
import YqOption from './components/option/YqOption.vue'
import { YqLayout, YqSidebar, YqHeader, YqContent, YqFooter } from './components/layout/index.ts'

// import YqSelect from './components/select/index.ts'
// import YqOption from './components/option/index.ts'

// 组件列表
const components: Record<string, Component> = {
  'yq-select': YqSelect,
  'yq-option': YqOption,
  'yq-layout': YqLayout,
  'yq-sidebar': YqSidebar,
  'yq-header': YqHeader,
  'yq-content': YqContent,
  'yq-footer': YqFooter
}

// 定义插件选项类型
interface YqWinPlusOptions {
  // 可以在这里添加插件配置选项
}

// 创建YqWin-Plus插件
const YqWinPlus: Plugin<[YqWinPlusOptions?]> = {
  install(app: App, _options: YqWinPlusOptions = {}) {
    // 注册自定义组件
    Object.keys(components).forEach(componentName => {
      app.component(componentName, components[componentName])
    })
    
    // 注册所有Element Plus图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  }
}

// 导出命名组件
export { YqSelect, YqOption, YqLayout, YqSidebar, YqHeader, YqContent, YqFooter }

// 导出MenuItem类型
export type { MenuItem } from './components/layout/YqSidebar.vue'

export default YqWinPlus